package com.mayikt.member.mapper;

import com.mayikt.member.entity.UserDo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Classname UserMapper
 * @Description SpringBoot SpringCloud 构建微服务电商平台。
 * @Created by CHEN JIN LONG
 * @Date 2019/1/19 01:10
 * @Version 1.0
 */
public interface UserMapper {

    /**
     * 新增用户
     * @param userDo
     * @return
     */
    @Insert("INSERT INTO `meite_user` (`USER_ID`, `MOBILE`, `EMAIL`, `PASSWORD`, `USER_NAME`, `SEX`, `AGE`, `CREATE_TIME`, `UPDATE_TIME`, `IS_AVALIBLE`, `PIC_IMG`, `QQ_OPENID`, `WX_OPENID`) VALUES (NULL, #{MOBILE}, #{EMAIL}, #{PASSWORD}, #{USER_NAME}, #{SEX}, #{AGE}, #{CREATE_TIME}, #{UPDATE_TIME}, #{IS_AVALIBLE}, #{PIC_IMG}, #{QQ_OPENID}, #{WX_OPENID});")
    int register(UserDo userDo);

    /**
     * 按手机号查询
     * @param mobile
     * @return
     */
    @Select("SELECT * FROM `meite_user` WHERE MOBILE=#{MOBILE}")
    UserDo existMobile(@Param("MOBILE") String mobile);

    /**
     * 按主键查询
     * @param userId
     * @return
     */
    @Select("SELECT * FROM `meite_user` WHERE USER_ID=#{USER_ID}")
    UserDo findByUserId(@Param("USER_ID") Long userId);

    /**
     * 登录查询
     * @param mobile
     * @param password
     * @return
     */
    @Select("SELECT * FROM `meite_user` WHERE MOBILE=#{MOBILE} AND `PASSWORD`=#{PASSWORD}")
    UserDo login(@Param("MOBILE") String mobile, @Param("PASSWORD") String password);
}

